<template>
  <el-dialog
    title="添加"
    :visible.sync="dialog"
    width="60%"
    :close-on-click-modal="false"
    close-on-press-escape
    @close="dialogClose"
  >
    <el-form ref="ruleForm" :model="obj" :rules="rules" label-width="0" class="rule-form">
      <div>
        <div class="title">动火作业许可证</div>
        <table>
          <tr>
            <td>编号</td>
            <td>
              <el-form-item prop="serialNumber">
                <el-input v-model="obj.serialNumber" clearable placeholder="请输入编号" />
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>流水号</td>
            <td>
              <el-form-item prop="singleNumber">
                <el-input v-model="obj.singleNumber" clearable placeholder="请输入流水号" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>申请动火单位</td>
            <td>
              <el-form-item prop="applyHotUnit">
                <el-input v-model="obj.applyHotUnit" clearable placeholder="请输入申请动火单位" />
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>动火施工单位</td>
            <td>
              <el-form-item prop="hotConstructionUnit">
                <el-input v-model="obj.hotConstructionUnit" clearable placeholder="请输入动火施工单位" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>动火级别</td>
            <td>
              <el-form-item prop="hotLevel">
                <el-input v-model="obj.hotLevel" clearable placeholder="请输入动火级别" />
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>动火地点</td>
            <td>
              <el-form-item prop="hotPlace">
                <el-input v-model="obj.hotPlace" clearable placeholder="请输入动火地点" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>动火时间</td>
            <td>
              <el-form-item prop="hotTime">
                <wise-date v-model="obj.hotTime" type="datetime" format="yyyy-MM-dd HH:mm:ss" />
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>动火内介质</td>
            <td>
              <el-form-item prop="hotInnerMedium">
                <el-input v-model="obj.hotInnerMedium" clearable placeholder="请输入动火内介质" />
              </el-form-item>
              <div class="hei10" />
            </td>

          </tr>
          <tr>
            <td>动火部位</td>
            <td colspan="3">
              <el-form-item prop="hotPart">
                <el-input v-model="obj.hotPart" clearable placeholder="请输入动火部位" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>动火原因</td>
            <td colspan="3">
              <el-form-item prop="hotReason">
                <el-input v-model="obj.hotReason" clearable placeholder="请输入动火原因" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>动火作业主要人员</td>
            <td colspan="3">
              <el-form-item prop="hotWorkUser">
                <el-input v-model="obj.hotWorkUser" clearable placeholder="请输入动火作业主要人员" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>
              动火方案是否审批：
              <el-form-item prop="isApproval">
                <el-radio-group v-model="obj.isApproval">
                  <el-radio :label="true">是</el-radio>
                  <el-radio :label="false">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </td>
            <td colspan="3">
              <div>其他附件（危害识别等）</div>
              <el-form-item prop="otherFileUrl">
                <wise-file v-model="obj.otherFileUrl" upload-type="file" :limit="6" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>
              是否附图纸：
              <el-radio-group v-model="obj.isDrawing">
                <el-radio :label="true">是</el-radio>
                <el-radio :label="false">否</el-radio>
              </el-radio-group>
              <div class="hei10" />
            </td>
            <td colspan="3">
              <div>图纸说明</div>
              <el-form-item
                prop="drawingUrl"
                :rules="[
                  {
                    required: obj.isDrawing,
                    message: '必填项不能为空',
                    trigger: 'blur'
                  }
                ]"
              >
                <wise-file v-model="obj.drawingUrl" upload-type="file" :limit="6" />
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td>有效期开始时间</td>
            <td>
              <el-form-item prop="startTime">
                <wise-date v-model="obj.startTime" type="datetime" format="yyyy-MM-dd HH:mm:ss" />
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>有效期结束时间</td>
            <td>
              <el-form-item prop="endTime">
                <wise-date v-model="obj.endTime" type="datetime" format="yyyy-MM-dd HH:mm:ss" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td colspan="4">
              <div>动火作业类型：</div>
              <el-form-item prop="hotWorkType">
                <el-checkbox-group v-model="obj.hotWorkType">
                  <el-checkbox v-for="item in hotWorkTypeData" :key="item.code" :label="item.code" name="hotWorkType">
                    {{ item.name }}
                  </el-checkbox>
                </el-checkbox-group>
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td colspan="4">
              <div>可能产生的危害：</div>
              <el-form-item prop="harmType">
                <el-checkbox-group v-model="obj.harmType">
                  <el-checkbox v-for="item in possibleHazardsData" :key="item.code" :label="item.code" name="harmType">
                    {{ item.name }}
                  </el-checkbox>
                </el-checkbox-group>
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td colspan="4">
              <div class="mr-b-20">
                <div>相关许可落实情况：</div>
                <el-form-item prop="licenseImplement">
                  <el-checkbox-group v-model="obj.licenseImplement">
                    <el-checkbox
                      v-for="item in implementationData"
                      :key="item.code"
                      :label="item.code"
                      name="licenseImplement"
                    >
                      {{ item.name }}
                    </el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </div>
              <div class="mr-b-20">
                是否开展JSA分析：
                <el-form-item prop="isJsa">
                  <el-radio-group v-model="obj.isJsa">
                    <el-radio :label="true">是</el-radio>
                    <el-radio :label="false">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </div>
              <div class="mr-b-20">
                相关说明：
                <el-form-item prop="jsaDescribe">
                  <el-input v-model="obj.jsaDescribe" clearable placeholder="请输入相关说明" type="textarea" />
                </el-form-item>
              </div>
              <div>
                JSA分析列表及管控措施：（附表）
                <el-form-item
                  prop="jsaAnalysis"
                  :rules="[
                    {
                      required: obj.isJsa,
                      message: '必填项不能为空',
                      trigger: 'blur'
                    }
                  ]"
                >
                  <wise-file v-model="obj.jsaAnalysis" upload-type="file" :limit="6" />
                </el-form-item>
              </div>
            </td>
          </tr>
          <tr>
            <td colspan="4">
              <div>安全措施：</div>
              <el-checkbox-group v-model="obj.safetyType">
                <el-checkbox v-for="item in safetyMeasuresData" :key="item.code" :label="item.code" name="safetyType">
                  {{ item.name }}
                </el-checkbox>
              </el-checkbox-group>
            </td>
          </tr>
        </table>
        <table class="hot-gas-detect">
          <tr>
            <td colspan="5">
              <el-row type="flex" justify="space-between" align="middle">
                <div>气体检测（动火指挥签字前应进行气体检测）：</div>
                <i class="el-icon-circle-plus-outline" @click="addHotGasDetectHandle" />
              </el-row>
            </td>
          </tr>
          <tr>
            <td>测试时间</td>
            <td>测试位置</td>
            <td>氧气测试浓度%</td>
            <td>可燃气体浓度LEL%</td>
            <td>有毒气体浓度%</td>
          </tr>
          <tr v-for="(item, index) in obj.hotGasDetectList" :key="index">
            <td>
              <el-form-item :prop="item.key">
                <wise-date
                  v-model="obj.hotGasDetectList[index]['testTime']"
                  clearable
                  type="datetime"
                  format="yyyy-MM-dd HH:mm:ss"
                />
              </el-form-item>
            </td>
            <td>
              <el-form-item :prop="item.key">
                <el-input v-model="obj.hotGasDetectList[index]['testPlace']" clearable placeholder="请输入测试位置" />
              </el-form-item>
            </td>
            <td>
              <el-form-item :prop="item.key">
                <el-input v-model="obj.hotGasDetectList[index]['oxygen']" clearable placeholder="请输入氧气测试浓度" />
              </el-form-item>
            </td>
            <td>
              <el-form-item :prop="item.key">
                <el-input v-model="obj.hotGasDetectList[index]['flammableGas']" clearable placeholder="请输入可燃气体浓度LEL" />
              </el-form-item>
            </td>
            <td>
              <el-row type="flex" align="middle">
                <el-col :span="20">
                  <el-form-item :prop="item.key">
                    <el-input v-model="obj.hotGasDetectList[index]['toxicGas']" clearable placeholder="请输入有毒气体浓度" />
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-row type="flex" justify="end">
                    <i v-if="index !== 0" class="el-icon-circle-close" @click="removeHotGasDetectHandle(index)" />
                  </el-row>
                </el-col>
              </el-row>
            </td>
          </tr>
        </table>
        <table>
          <tr>
            <td colspan="5">
              <el-row :gutter="50">
                <el-col class="mr-b-20">本人确认工作开始前气体检测已合格。</el-col>
                <el-col :span="12">
                  <el-row type="flex" align="middle">
                    <el-col :span="10">检测人（动火作业单位监护人）：</el-col>
                    <el-col :span="14">
                      <el-form-item prop="gasInspector">
                        <el-select v-model="obj.gasInspector" placeholder="请选择" @change="changeGasInspector">
                          <el-option
                            v-for="item in temporaryWorkersData"
                            :key="item.userId"
                            :label="item.username"
                            :value="item.userId"
                          />
                        </el-select>
                      </el-form-item>
                      <div class="hei10" />
                    </el-col>
                  </el-row>
                </el-col>
                <el-col :span="12">
                  <el-row type="flex" align="middle">
                    <el-col :span="10">确认人（属地单位监护人）：</el-col>
                    <el-col :span="14">
                      <el-form-item prop="gasConfirmUser">
                        <el-select v-model="obj.gasConfirmUser" placeholder="请选择" @change="changeGasConfirmUser">
                          <el-option
                            v-for="item in temporaryWorkersZSGData"
                            :key="item.userId"
                            :disabled="item.disabled"
                            :label="item.username"
                            :value="item.userId"
                          />
                        </el-select>
                      </el-form-item>
                      <div class="hei10" />
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <td colspan="5">
              <div>
                注明作业过程中气体测试要求（位置、频次等）：（当气体检测表格不够填时可按本许可证内容、格式另附气体检测表格，须在此处说明）
              </div>
              <el-form-item prop="gasTestRequire">
                <el-input v-model="obj.gasTestRequire" placeholder="请输入气体测试要求" :rows="3" type="textarea" />
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>安全监护人</td>
            <td colspan="4">
              <div class="mr-b-20">本人已阅读许可并且确信所以条件都满足，并承诺坚守现场。</div>
              <el-row>
                <el-col :span="14">
                  <el-row type="flex" align="middle">
                    <el-col :span="8">现场所有安全监护人：</el-col>
                    <el-col :span="16">
                      <el-form-item prop="safetyUserId">
                        <el-select v-model="obj.safetyUserId" placeholder="请选择" @change="changeSafetyUserId">
                          <el-option
                            v-for="item in memberData"
                            :key="item.userId"
                            :label="item.username"
                            :value="item.userId"
                          />
                        </el-select>
                      </el-form-item>
                      <div class="hei10" />
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <td>相关方</td>
            <td colspan="4">
              <div class="mr-b-20">本人确认收到许可证，了解工作对本单位的影响，将安排人员对此项工作给予关注，并和相关各方保持联系。</div>
              <el-row>
                <el-col :span="14">
                  <el-row type="flex" align="middle">
                    <el-col :span="4">确认人：</el-col>
                    <el-col :span="16">
                      <el-form-item prop="relatedUserId">
                        <el-select v-model="obj.relatedUserId" placeholder="请选择" @change="changeRelatedUserId">
                          <el-option
                            v-for="item in memberData"
                            :key="item.userId"
                            :label="item.username"
                            :value="item.userId"
                          />
                        </el-select>
                      </el-form-item>
                      <div class="hei10" />
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <td colspan="5">
              <el-row type="flex" align="middle">
                <el-col :span="5">动火施工单位现场负责人签字：</el-col>
                <el-col :span="8">
                  <el-form-item prop="constructionUnitUserId">
                    <el-select
                      v-model="obj.constructionUnitUserId"
                      placeholder="请选择"
                      @change="changeConstructionUnitUserId"
                    >
                      <el-option
                        v-for="item in temporaryWorkersData"
                        :key="item.userId"
                        :label="item.username"
                        :value="item.userId"
                      />
                    </el-select>
                  </el-form-item>
                  <div class="hei10" />
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <td colspan="5">
              <el-row type="flex" align="middle">
                <el-col :span="6">申请动火单位主管部门负责人签字：</el-col>
                <el-col :span="8">
                  <el-form-item prop="applyHotUnitUserId">
                    <el-select v-model="obj.applyHotUnitUserId" placeholder="请选择" @change="changeApplyHotUnitUserId">
                      <el-option
                        v-for="item in memberData"
                        :key="item.userId"
                        :label="item.username"
                        :value="item.userId"
                      />
                    </el-select>
                  </el-form-item>
                  <div class="hei10" />
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <td>上级主管部门（特级、一级动火）</td>
            <td>
              <div>生产调度运行部门签字：</div>
              <el-form-item prop="productionAdminUserId">
                <el-select v-model="obj.productionAdminUserId" placeholder="请选择" @change="changeProductionAdminUserId">
                  <el-option
                    v-for="item in memberData"
                    :key="item.userId"
                    :label="item.username"
                    :value="item.userId"
                  />
                </el-select>
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>
              <div>资产设施管理部门签字：</div>
              <el-form-item prop="assetsAdminUserId">
                <el-select v-model="obj.assetsAdminUserId" placeholder="请选择" @change="changeAssetsAdminUserId">
                  <el-option
                    v-for="item in memberData"
                    :key="item.userId"
                    :label="item.username"
                    :value="item.userId"
                  />
                </el-select>
              </el-form-item>
              <div class="hei10" />
            </td>
            <td>
              <div>安全监管部门签字：</div>
              <el-form-item prop="safetyAdminUserId">
                <el-select v-model="obj.safetyAdminUserId" placeholder="请选择" @change="changeSafetyAdminUserId">
                  <el-option
                    v-for="item in memberData"
                    :key="item.userId"
                    :label="item.username"
                    :value="item.userId"
                  />
                </el-select>
              </el-form-item>
              <div class="hei10" />
            </td>
          </tr>
          <tr>
            <td>作业批准人（动火现场指挥）</td>
            <td colspan="4">
              <div class="mr-b-20">
                我已审核过本许可证的相关文件，并确认符合公司动火安全管理规定的要求，同时我与相关人员一同检查过现场并同意动火方案，因此，我同意动火。
              </div>
              <el-row type="flex" align="middle">
                <el-col :span="2">签字：</el-col>
                <el-col :span="6">
                  <el-form-item prop="entAdminUserId">
                    <el-select v-model="obj.entAdminUserId" placeholder="请选择" @change="changeEntAdminUserId">
                      <el-option
                        v-for="item in approvalData"
                        :key="item.userId"
                        :label="item.username"
                        :value="item.userId"
                      />
                    </el-select>
                  </el-form-item>
                  <div class="hei10" />
                </el-col>
              </el-row>
            </td>
          </tr>
          <tr>
            <td colspan="5">
              <div>变动备注栏（填写组织机构人员变动等实际情况）</div>
              <el-form-item prop="remark">
                <el-input v-model="obj.remark" clearable placeholder="请输入相关说明" type="textarea" :rows="3" />
              </el-form-item>
            </td>

          </tr>
          <tr>
            <td colspan="5">
              注：1.本许可证一式四联：第一联由批准人持有，第二联由基层单位持有，第三联由现场监护人持有，第四联由施工单位现场负责人持有。
            </td>
          </tr>
        </table>
      </div>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialog = false">取 消</el-button>
      <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import WiseDate from '@/components/Crud/components/wiseDate'
import WiseFile from '@/components/Crud/components/wiseFile'
import {
  mixin
} from './hotTicket'
import {
  postHandle
} from '../../../../../api'
export default {
  components: {
    WiseDate,
    WiseFile
  },
  mixins: [mixin],
  data() {
    return {
      dialog: false,
      isSubminBtn: false,
      obj: {
        hotGasDetectList: [{
          testTime: null,
          testPlace: '',
          oxygen: '',
          flammableGas: '',
          toxicGas: ''
        }],
        serialNumber: null,
        singleNumber: null,
        applyHotUnit: null,
        hotConstructionUnit: null,
        hotLevel: null,
        hotPlace: null,
        hotTime: null,
        hotInnerMedium: null,
        hotPart: null,
        hotReason: null,
        hotWorkUser: null,
        isApproval: null,
        otherFileUrl: null,
        isDrawing: null,
        drawingUrl: null,
        startTime: null,
        endTime: null,
        hotWorkType: [],
        harmType: [],
        licenseImplement: [],
        safetyType: [],
        isJsa: null,
        jsaDescribe: null,
        jsaAnalysis: null,
        gasTestRequire: null,
        safetyUserId: null,
        relatedUserId: null,
        constructionUnitUserId: null,
        applyHotUnitUserId: null,
        productionAdminUserId: null,
        assetsAdminUserId: null,
        safetyAdminUserId: null,
        entAdminUserId: null,
        remark: null,
        gasInspector: null,
        gasConfirmUser: null
      },
      rules: {
        serialNumber: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        singleNumber: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        applyHotUnit: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotConstructionUnit: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotLevel: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotPlace: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotTime: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotInnerMedium: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotPart: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotReason: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotWorkUser: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        isApproval: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        otherFileUrl: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        isDrawing: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        // drawingUrl: [
        //   {
        //     required: true,
        //     message: '必填项不能为空',
        //     trigger: 'blur'
        //   }
        // ],
        startTime: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        endTime: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        hotWorkType: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        harmType: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        licenseImplement: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        isJsa: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        jsaDescribe: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        // jsaAnalysis: [
        //   {
        //     required: true,
        //     message: '必填项不能为空',
        //     trigger: 'blur'
        //   }
        // ],
        safetyType: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        gasTestRequire: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        safetyUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        relatedUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        constructionUnitUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        applyHotUnitUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        productionAdminUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        assetsAdminUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        safetyAdminUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        entAdminUserId: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        gasInspector: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }],
        gasConfirmUser: [{
          required: true,
          message: '必填项不能为空',
          trigger: 'blur'
        }]
      }
    }
  },
  methods: {
    changeGasConfirmUser(val) {
      if (val != this.obj.gasConfirmUser) {
        this.isSubminBtn = true
      }
    },
    changeGasInspector(val) {
      if (val != this.obj.gasInspector) {
        this.isSubminBtn = true
      }
    },
    changeConstructionUnitUserId(val) {
      if (val != this.obj.temporaryWorkersData) {
        this.isSubminBtn = true
      }
    },

    changeSafetyUserId(val) {
      if (val != this.obj.safetyUserId) {
        this.isSubminBtn = true
      }
    },

    changeRelatedUserId(val) {
      if (val != this.obj.relatedUserId) {
        this.isSubminBtn = true
      }
    },

    changeApplyHotUnitUserId(val) {
      if (val != this.obj.applyHotUnitUserId) {
        this.isSubminBtn = true
      }
    },

    changeProductionAdminUserId(val) {
      if (val != this.obj.productionAdminUserId) {
        this.isSubminBtn = true
      }
    },

    changeSafetyAdminUserId(val) {
      if (val != this.obj.safetyAdminUserId) {
        this.isSubminBtn = true
      }
    },
    changeAssetsAdminUserId(val) {
      if (val != this.obj.assetsAdminUserId) {
        this.isSubminBtn = true
      }
    },
    changeEntAdminUserId(val) {
      if (val != this.obj.entAdminUserId) {
        this.isSubminBtn = true
      }
    },

    showAddDsalog(id) {
      this.getHotWorkTypeData()
      this.getPossibleHazardsData()
      this.getImplementationData()
      this.getSafetyMeasuresData()
      this.getMembersData()
      this.getApprovalData()
      this.getTemporaryWorkersData()
      this.getTemporaryWorkersZSGData()
      if (id != undefined) {
        this.getObjectId(id)
        return false
      }

      this.dialog = true
    },

    // 详情
    getObjectId(id) {
      postHandle(`/api/v1/welder-sbtx-second/hot-ticket-comb/show/${id}`).then(res => {
        this.obj = res.result
        let {
          hotWorkType,
          harmType,
          licenseImplement,
          safetyType
        } = this.obj
        this.obj.hotWorkType = hotWorkType.split(',')
        this.obj.harmType = harmType.split(',')
        this.obj.licenseImplement = licenseImplement.split(',')
        this.obj.safetyType = safetyType.split(',')
        this.dialog = true
        if (this.temporaryWorkersZSGData.findIndex(item => item.userId == this.obj.gasConfirmUser) === -1) {
          this.isSubminBtn = false
          this.temporaryWorkersZSGData.push({
            userId: this.obj.gasConfirmUser,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.temporaryWorkersData.findIndex(item => item.userId == this.obj.gasInspector) === -1) {
          this.isSubminBtn = false
          this.temporaryWorkersData.push({
            userId: this.obj.gasInspector,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.temporaryWorkersData.findIndex(item => item.userId == this.obj.constructionUnitUserId) === -1) {
          this.isSubminBtn = false
          this.temporaryWorkersData.push({
            userId: this.obj.constructionUnitUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.memberData.findIndex(item => item.userId == this.obj.safetyUserId) === -1) {
          this.isSubminBtn = false
          this.memberData.push({
            userId: this.obj.safetyUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.memberData.findIndex(item => item.userId == this.obj.relatedUserId) === -1) {
          this.isSubminBtn = false
          this.memberData.push({
            userId: this.obj.relatedUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.memberData.findIndex(item => item.userId == this.obj.applyHotUnitUserId) === -1) {
          this.isSubminBtn = false
          this.memberData.push({
            userId: this.obj.applyHotUnitUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.memberData.findIndex(item => item.userId == this.obj.productionAdminUserId) === -1) {
          this.isSubminBtn = false
          this.memberData.push({
            userId: this.obj.productionAdminUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.memberData.findIndex(item => item.userId == this.obj.assetsAdminUserId) === -1) {
          this.isSubminBtn = false
          this.memberData.push({
            userId: this.obj.assetsAdminUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
        if (this.memberData.findIndex(item => item.userId == this.obj.safetyAdminUserId) === -1) {
          this.isSubminBtn = false
          this.memberData.push({
            userId: this.obj.safetyAdminUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }

        if (this.approvalData.findIndex(item => item.userId == this.obj.entAdminUserId) === -1) {
          this.isSubminBtn = false
          this.approvalData.push({
            userId: this.obj.entAdminUserId,
            username: '用户不存在!',
            disabled: true
          })
        } else {
          this.isSubminBtn = true
        }
      })
    },
    addHotGasDetectHandle() {
      if (this.obj.hotGasDetectList.length >= 6) {
        this.$message.error('最多只能添加6个')
        return
      }
      this.obj.hotGasDetectList.push({
        testTime: null,
        testPlace: '',
        oxygen: '',
        flammableGas: '',
        toxicGas: ''
      })
    },
    removeHotGasDetectHandle(i) {
      this.obj.hotGasDetectList.splice(i, 1)
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.isSubminBtn ? this.formHandle() : this.$message.error('用户不存在!请重新选择')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    formHandle() {
      let obj = JSON.parse(JSON.stringify(this.obj))
      let url
      let {
        hotWorkType,
        harmType,
        licenseImplement,
        safetyType
      } = obj
      obj.hotWorkType = hotWorkType.join(',')
      obj.harmType = harmType.join(',')
      obj.licenseImplement = licenseImplement.join(',')
      obj.safetyType = safetyType.join(',')
      if (!obj.isDrawing) {
        obj.drawingUrl = null
      }
      if (!obj.isJsa) {
        obj.jsaAnalysis = null
      }

      if (this.obj.id) {
        url = `/api/v1/welder-sbtx-second/hot-ticket-comb/update/${this.obj.id}`
        obj.hotGasDetectList = obj.hotGasDetectList.map(item => {
          return {
            testTime: item.testTime,
            testPlace: item.testPlace,
            oxygen: item.oxygen,
            flammableGas: item.flammableGas,
            toxicGas: item.toxicGas
          }
        })
      } else {
        url = '/api/v1/welder-sbtx-second/hot-ticket-comb/create'
      }
      postHandle(url, {
        obj
      }).then(res => {
        this.$message.success('成功')
        this.$emit('refreshTable')
        this.dialog = false
      })
    },
    dialogClose() {
      setTimeout(() => {
        this.$refs['ruleForm'].resetFields()
        this.obj = {
          hotGasDetectList: [{
            testTime: null,
            testPlace: '',
            oxygen: '',
            flammableGas: '',
            toxicGas: ''
          }],
          serialNumber: null,
          singleNumber: null,
          applyHotUnit: null,
          hotConstructionUnit: null,
          hotLevel: null,
          hotPlace: null,
          hotTime: null,
          hotInnerMedium: null,
          hotPart: null,
          hotReason: null,
          hotWorkUser: null,
          isApproval: null,
          otherFileUrl: null,
          isDrawing: null,
          drawingUrl: null,
          startTime: null,
          endTime: null,
          hotWorkType: [],
          harmType: [],
          licenseImplement: [],
          isJsa: null,
          jsaDescribe: null,
          jsaAnalysis: null,
          safetyType: [],
          gasTestRequire: null,
          safetyUserId: null,
          relatedUserId: null,
          constructionUnitUserId: null,
          applyHotUnitUserId: null,
          productionAdminUserId: null,
          assetsAdminUserId: null,
          safetyAdminUserId: null,
          entAdminUserId: null,
          remark: null,
          gasInspector: null,
          gasConfirmUser: null
        }
        this.$emit('reload', false)
      })
    }
  }
}
</script>

<style lang="less" scoped>
  .title {
    text-align: center;
    border: none;
    margin-bottom: 20px;
  }

  .number {
    text-align: right;
    border: none;
    width: 95%;
    margin-bottom: 20px;
  }

  table {
    border-collapse: collapse;
    width: 100%;
    border: 1px solid;
    text-align: left;

    td {
      line-height: 18px;
      border: 1px solid;
      padding: 7px;
    }

    td:nth-child(odd) {
      width: 20%;
    }
  }

  .hot-gas-detect {
    //   td:nth-child(1) {
    //     width: initial;
    //   }

    //   td:nth-child(odd) {
    //     width: initial;
    //   }

    //   td:not(:nth-child(1)) {
    //     width: 14%;
    //   }
  }

  .hot-gas-detect+table {
    td:nth-child(odd) {
      width: initial;
    }

    td {
      width: 20%;
    }
  }

  .image {
    width: 100px;
    height: 100px;
  }

  // .padding10 {
  //   padding-right: 50px;
  // }

  .el-form-item {
    margin-bottom: 0;
  }

  .mr-b-20 {
    margin-bottom: 20px;
  }

  .el-icon-circle-plus-outline,
  .el-icon-circle-close {
    font-size: 24px;
    color: #409eff;
    cursor: pointer;
  }

  .hei10 {
    height: 10px;
  }
</style>
